<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>重建索引</title>
    <script type="text/javascript">
      Ext.onReady(function(){
        var beginDate = new Ext.form.DateField({
          fieldLabel: '日期从',
          name: 'begin_date',
          id: 'begin_date',
          format: 'Y-m-d', //格式化日期
          //disabledDays: [0,6],	//不让选择周六，周日
          //disabledDaysText: "周末要休息",
          allowBlank: false,
          invalidText: "您输入的日期格式不对，正确格式为2010-01-01",
          inputType: '2010-01-01',
          anchor: '95%',
          vtype: 'daterange',
          endDateField: 'end_date',
          listeners: {
            select: function(field, e){
              //Ext.MessageBox.alert('提示', '提交成功');
            }
          },
          anchor: '100%'
        });
        
        var endDate = new Ext.form.DateField({
          fieldLabel: '至    ',
          name: 'end_date',
          id: 'end_date',
          format: 'Y-m-d', //格式化日期
          //disabledDays: [0,6],	//不让选择周六，周日
          //disabledDaysText: "周末要休息",
          allowBlank: false,
          invalidText: "您输入的日期格式不对，正确格式为2010-01-01",
          inputType: '2010-01-01',
          anchor: '95%',
          vtype: 'daterange',
          startDateField: 'begin_date',
          listeners: {
            select: function(field, e){
              //Ext.MessageBox.alert('提示', '提交成功');
            }
          },
          anchor: '100%'
        });
        
        var submitButton = new Ext.Button({
          text: '重建索引',
          width:70,
          handler: function(){
            if (reindexFormPanel.form.isValid()){
              this.disable();
              reindexFormPanel.form.submit({
                success: function(result, resp){
                  if (resp.result.info.indexOf("成功") >= 0) {
                    Ext.MessageBox.show({
                      title: '消息',
                      msg: "重建索引，操作成功！",
                      buttons: Ext.MessageBox.OK,
                      icon: Ext.MessageBox.INFO
                    });
                  } else {
                    Ext.MessageBox.show({
                      title: '消息',
                      msg: resp.result.info,
                      buttons: Ext.MessageBox.OK,
                      icon: Ext.MessageBox.WARNING
                    });
                  }
                  submitButton.enable();
                },
                failure: function(result, request){
                  Ext.MessageBox.show({
                    title: '消息',
                    msg: "通讯失败，请从新操作",
                    buttons: Ext.MessageBox.OK,
                    icon: Ext.MessageBox.WARNING
                  });
                }
              });
            }
          }
        });

        var clearButton = new Ext.Button({
          text: '清空',
          width:50,
          handler: function(){
            reindexFormPanel.form.reset();
          }
        });

        var reindexFormPanel = new Ext.form.FormPanel({
          //baseCls: 'x-plain',
          renderTo: 'reindex_form',
          url: '/admin/reindex',
          timeout: 120000,
          method: 'GET',
          labelWidth: 60,
          width: screenWidth-175,
          labelAlign: 'right',
          frame : true,
          border:false,
          items: [{
              layout: 'column',
              border: false,
              items: [{
                  columnWidth: .13,
                  layout: 'form',
                  border: false,
                  items: [beginDate]
                }, {
                  columnWidth: .13,
                  layout: 'form',
                  border: false,
                  items: [endDate]
                }, {
                  columnWidth: .11,
                  layout: 'form',
                  border: false,
                  items: [submitButton]
                }, {
                  columnWidth: .11,
                  layout: 'form',
                  border: false,
                  items: [clearButton]
                }]
            }]
        });
      })
    </script>
  </head>
  <body>
    <div id="reindex_form"></div>
  </body>
</html>